<?php

class Test_Abovo_Model_Product extends Solar_Test {
    
    public function setup()
    {
        // register a Solar_Sql object if not already
        if (! Solar::isRegistered('sql')) {
            Solar::register('sql', Solar::factory('Solar_Sql'));
        }
    }
    
    public function testOverloadPropertyAsTag()
    {
        $this->_products = Solar::factory('ProductTypeTest');
        
        $data = array(
            'handle'     => 'antti',
            'productnum' => '1234',
            'name'       => 'This is a test product',
            'brand'      => 'Test products',
            'vat'        => 22,
            'colour'     => 'white 123',
            'size'       => 'XL',
        );
        
        $new = $this->_products->save($data);
        
        $saved = $this->_products->fetch(1);
        
        $tags = array(
            'colour:white 123',
            'size:XL',
        );
        
        $this->assertSame($this->_products->tags->fetchAll($saved['id']), $tags);
        
    }
}

Solar::loadClass('Abovo_Model_Product_Type_Abstract');
class ProductTypeTest extends Abovo_Model_Product_Type_Abstract {
    
    protected $_tag_cols = array(
        'colour',
        'size',
    );
}
